package com.edu.controller;

import com.edu.entity.CommonResult;
import com.edu.entity.User;
import com.edu.feign.UserServiceProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/cart")
@LoadBalancerClient(name = "user-provider-service")
public class CartController {
    //   注入Fegin接口（@EnableFeignClients自动扫描@FeignClient注解）
    @Autowired
    private UserServiceProviderService userServiceProviderService;

    @GetMapping("/getUserById/{userId}")
    @LoadBalanced
    public CommonResult<User> getUserById(@PathVariable("userId") Integer userId) {
        CommonResult<User> result = userServiceProviderService.getUserById(userId);
        System.out.println("运行正常");
        return result;
    }


}


